#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i(a);i<=(b);++i)
#define req(i,a,b) for(int i(a);i>=(b);--i)
#define sort stable_sort
using namespace std;
char buf[1<<23],*p1=buf,*p2=buf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?EOF:*p1++)
template<typename TP> inline TP read(TP &num)
{
	TP x=0;
	int f=0;
	char ch=getchar();
	while(ch<48||ch>57) f|=ch=='-',ch=getchar();
	while(48<=ch&&ch<=57) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return num=f?-x:x;
}
template<typename ...Args> inline void read(Args &...args)
{
	(read(args),...);
}
template<typename TP> inline void write(TP x)
{
	(x<0)?(putchar('-'),x=-x):0;
	(x>9)?(write(x/10),0):0;
	putchar((x%10)^48);
}
template<typename TP> inline void writeln(TP x)
{
	write<TP>(x);
	puts("");
}
struct dsu
{
	vector<int> fa,siz;
	dsu(int n):fa(n),siz(n,1){iota(fa.begin(),fa.end(),0);}
	int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
	inline void unite(int x,int y){x=find(x),y=find(y);if(x!=y)fa[x]=y;}
};
signed main()
{
	freopen("destory.in","r",stdin);
	freopen("destory.out","w",stdout);
	int n,m,q; read(n,m,q);
	dsu d(n+1);
	rep(i,1,m)
	{
		int x,y; read(x,y);
		d.unite(x,y);
	}
	vector<int> belong(n+1);
	rep(i,1,n) belong[i]=d.find(i);
	while(q--)
	{
		int l,r; read(l,r);
		set<int> s; rep(i,l,r) s.emplace(belong[i]);
		map<int,int> mp;
		int ptr=l,ans=1e18;
		rep(L,l,r)
		{
			while(mp.size()<s.size()&&ptr<=r) ++mp[belong[ptr++]];
			if(mp.size()<s.size()) break;
			ans=min(ans,ptr-L);
			if(!--mp[belong[L]]) mp.erase(belong[L]);
		}
		writeln(ans);
	}
	return 0;
}
